package mil.af.amc.adpetracker.model;

import java.math.BigDecimal;
import java.text.NumberFormat;
import java.util.Locale;

/**
 * Please fill in this javadoc
 *
 * @author TSgt Jason Ferguson
 */
public class DD13481A extends PdfForm {

    public DD13481A() {

        setFormName("DD Form 1348-1A");
        setFormVersion("Jul 91");
    }

    public void setQuantity(int quantity) {

        char[] charQuantity = Integer.toString(quantity).toCharArray();
        int length = charQuantity.length;

        if (length==5) {
            formData.put("F[0].P1[0].FillText30[0]",charQuantity[4]);
            formData.put("F[0].P1[0].FillText29[0]", charQuantity[3]);
            formData.put("F[0].P1[0].FillText28[0]", charQuantity[2]);
            formData.put("F[0].P1[0].FillText27[0]", charQuantity[1]);
            formData.put("F[0].P1[0].FillText26[0]", charQuantity[0]);
        }

        if (length==4) {
            formData.put("F[0].P1[0].FillText30[0]", charQuantity[3]);
            formData.put("F[0].P1[0].FillText29[0]", charQuantity[2]);
            formData.put("F[0].P1[0].FillText28[0]", charQuantity[1]);
            formData.put("F[0].P1[0].FillText27[0]", charQuantity[0]);
        }

        if (length==3) {
            formData.put("F[0].P1[0].FillText30[0]", charQuantity[2]);
            formData.put("F[0].P1[0].FillText29[0]", charQuantity[1]);
            formData.put("F[0].P1[0].FillText28[0]", charQuantity[0]);
        }

        if (length==2) {
            formData.put("F[0].P1[0].FillText30[0]", charQuantity[1]);
            formData.put("F[0].P1[0].FillText29[0]", charQuantity[0]);
        }

        if (length==1) {
            formData.put("F[0].P1[0].FillText30[0]", charQuantity[0]);
        }


    }

    public void setDemil(char demilCode) {

        throw new UnsupportedOperationException();

    }

    public void setItemCondition(char conditionCode) {

        throw new UnsupportedOperationException();
    }

    public void setUnitPrice(BigDecimal unitPrice) {

        NumberFormat n = NumberFormat.getCurrencyInstance(Locale.US);
        String format = n.format(unitPrice.doubleValue());

        String[] splitPrice = format.split(".");
        char[] price = format.toCharArray();

        for (int i=0; i<price.length; i++) {

        }


    }

    public void setTotalPrice(double totalPrice) {

    }

    public void setShipFrom(String shipFrom) {

        formData.put("F[0].P1[0].x2_SHIP_FROM[0]", shipFrom);

    }

    public void setShipTo(String shipTo) {

        formData.put("F[0].P1[0].x3_SHIP_TO[0]", shipTo);

    }

    public void setNomenclature(String nomenclature) {

        formData.put("F[0].P1[0].x17_ITEM_NOMENCLATURE[0]", nomenclature);

    }

    public void setNSN(String NSN) {

        formData.put("F[0].P1[0].FillText60[0]", NSN);
    }

    public void setBlock26(String data) {
        formData.put("F[0].P1[0].FillText61[0]", data);
    }

    public void setAdditionalData(String additionalData) {
        formData.put("F[0].P1[0].FillText62[0]", additionalData);
    }





}
